home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Database Designers / Rational Rose 2000 / Rational Setup.EXE / common / lib / Win32API / Net.pm next >
Encoding:
Perl POD Document  |  1998-11-15  |  46.1 KB  |  1,799 lines

  1. package Win32API::Net;
  2.  
  3. use strict;
  4. use Carp;
  5. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
  6.  
  7. require Exporter;
  8. require DynaLoader;
  9.  
  10. @ISA = qw(Exporter DynaLoader);
  11. # Items to export into callers namespace by default. Note: do not export
  12. # names by default without a very good reason. Use EXPORT_OK instead.
  13. # Do not simply export all your public functions/methods/constants.
  14. @EXPORT = qw();    # don't pollute callees namespace
  15.  
  16. %EXPORT_TAGS=(
  17.     User => [ qw(
  18.         FILTER_INTERDOMAIN_TRUST_ACCOUNT FILTER_NORMAL_ACCOUNT
  19.         FILTER_SERVER_TRUST_ACCOUNT FILTER_TEMP_DUPLICATE_ACCOUNTS
  20.         FILTER_WORKSTATION_TRUST_ACCOUNT
  21.         USER_ACCT_EXPIRES_PARMNUM USER_AUTH_FLAGS_PARMNUM
  22.         USER_CODE_PAGE_PARMNUM USER_COMMENT_PARMNUM USER_COUNTRY_CODE_PARMNUM
  23.         USER_FLAGS_PARMNUM USER_FULL_NAME_PARMNUM USER_HOME_DIR_DRIVE_PARMNUM
  24.         USER_HOME_DIR_PARMNUM USER_LAST_LOGOFF_PARMNUM USER_LAST_LOGON_PARMNUM
  25.         USER_LOGON_HOURS_PARMNUM USER_LOGON_SERVER_PARMNUM
  26.         USER_MAX_STORAGE_PARMNUM USER_NAME_PARMNUM USER_NUM_LOGONS_PARMNUM
  27.         USER_PAD_PW_COUNT_PARMNUM USER_PARMS_PARMNUM USER_PASSWORD_AGE_PARMNUM
  28.         USER_PASSWORD_PARMNUM USER_PRIMARY_GROUP_PARMNUM USER_PRIV_ADMIN
  29.         USER_PRIV_GUEST USER_PRIV_MASK USER_PRIV_PARMNUM USER_PRIV_USER
  30.         USER_PROFILE_PARMNUM USER_PROFILE_PARMNUM USER_SCRIPT_PATH_PARMNUM
  31.         USER_UNITS_PER_WEEK_PARMNUM USER_USR_COMMENT_PARMNUM
  32.         USER_WORKSTATIONS_PARMNUM LG_INCLUDE_INDIRECT
  33.         UF_ACCOUNTDISABLE UF_ACCOUNT_TYPE_MASK UF_DONT_EXPIRE_PASSWD
  34.         UF_HOMEDIR_REQUIRED UF_INTERDOMAIN_TRUST_ACCOUNT UF_LOCKOUT
  35.         UF_MACHINE_ACCOUNT_MASK UF_NORMAL_ACCOUNT UF_PASSWD_CANT_CHANGE
  36.         UF_PASSWD_NOTREQD UF_SCRIPT UF_SERVER_TRUST_ACCOUNT UF_SETTABLE_BITS
  37.         UF_TEMP_DUPLICATE_ACCOUNT UF_WORKSTATION_TRUST_ACCOUNT
  38.         UserAdd UserChangePassword UserDel UserEnum UserGetGroups UserGetInfo 
  39.         UserGetLocalGroups UserModalsGet UserModalsSet UserSetGroups
  40.         UserSetInfo
  41.     )],
  42.     Get => [ qw(
  43.         GetDCName
  44.     )],
  45.     Group => [ qw(
  46.         GROUP_ATTRIBUTES_PARMNUM GROUP_COMMENT_PARMNUM GROUP_NAME_PARMNUM
  47.         GroupAdd GroupAddUser GroupDel GroupDelUser GroupEnum GroupGetInfo 
  48.         GroupGetUsers GroupSetInfo GroupSetUsers 
  49.     )],
  50.     LocalGroup => [ qw(
  51.         LOCALGROUP_COMMENT_PARMNUM LOCALGROUP_NAME_PARMNUM
  52.         LocalGroupAdd LocalGroupAddMember LocalGroupAddMembers LocalGroupDel 
  53.         LocalGroupDelMember LocalGroupDelMembers LocalGroupEnum 
  54.         LocalGroupGetInfo LocalGroupGetMembers LocalGroupSetInfo 
  55.         LocalGroupSetMembers 
  56.     )],
  57. );
  58.  
  59. @EXPORT_OK= ();
  60. { my $ref;
  61.     foreach $ref (  values(%EXPORT_TAGS)  ) {
  62.         push( @EXPORT_OK, @$ref );
  63.     }
  64. }
  65. $EXPORT_TAGS{ALL}= \@EXPORT_OK;
  66.  
  67. $VERSION = '0.04';
  68.  
  69. sub AUTOLOAD {
  70.     my $constname;
  71.     ($constname = $AUTOLOAD) =~ s/.*:://;
  72.     my $val = constant($constname, @_ ? $_[0] : 0);
  73.     if ($! != 0) {
  74.     if ($! =~ /Invalid/) {
  75.         $AutoLoader::AUTOLOAD = $AUTOLOAD;
  76.         goto &AutoLoader::AUTOLOAD;
  77.     }
  78.     else {
  79.         croak "Your vendor has not defined Win32API::Net macro $constname";
  80.     }
  81.     }
  82.     eval "sub $AUTOLOAD { $val }";
  83.     goto &$AUTOLOAD;
  84. }
  85.  
  86. bootstrap Win32API::Net $VERSION;
  87.  
  88. 1;
  89. __END__
  90.  
  91. =head1 NAME
  92.  
  93. Win32API::Net - Perl interface to the Windows NT LanManager API account management functions.
  94.  
  95. =head1 SYNOPSIS
  96.  
  97. use Win32API::Net;
  98.  
  99. =head1 DESCRIPTION
  100.  
  101. Win32API::Net provides a more complete wrapper for the account management
  102. parts of the NT LanManager API than do other similar packages. Most of what
  103. you can achieve with the native C++ API is possible with this package - albeit
  104. in a more Perl like manner by using references to pass information to and
  105. from functions.
  106.  
  107. For an understanding of the environment in which these functions operate see
  108. L<DATA STRUCTURES>.
  109.  
  110. The following groups of functions are available:
  111.  
  112. =over 8
  113.  
  114. =item L<NET USER FUNCTIONS>
  115.  
  116. =item L<NET GROUP FUNCTIONS>
  117.  
  118. =item L<NET LOCAL GROUP FUNCTIONS>
  119.  
  120. =item L<NET GET FUNCTIONS>
  121.  
  122. =back
  123.  
  124. All functions return 0 on failure and 1 on success. Use the
  125. C<Win32::GetLastError()> function to find out more information on why a
  126. function failed. In addition, some functions that take a hash reference
  127. to pass information in (e.g. C<UserAdd()>) have a last argument that will
  128. allow more detailed information on which key/value pair was not properly
  129. specified.
  130.  
  131. =head2 Using References
  132.  
  133. References to hashes and arrays are used throughout this package to pass
  134. information into and out of functions.
  135.  
  136. =over 8
  137.  
  138. =item Using Hash References
  139.  
  140. Where a hash reference is required you can use anything that evaluates to a
  141. hash reference. e.g.
  142.  
  143.     $href = \%someHash;
  144.     UserAdd(server, 2, $hRef);
  145.  
  146. Or more directly:
  147.  
  148.     UserAdd(server, 2, \%someHash);
  149.  
  150. =item Using Array references
  151.  
  152. Array references are used in a similar manner to hash references. e.g.
  153.  
  154.     $aref = \@someArray;
  155.     UserEnum(server, $aref);
  156.  
  157. Or more directly:
  158.  
  159.     UserEnum(server, \@someArray);
  160.  
  161. =back
  162.  
  163. Please note: Any C<*Get*()> or C<*Enum()> operation will first clear the
  164. contents of the input hash or array being referenced.
  165.  
  166. See L<EXAMPLES> and the test.pl script for examples of usage.
  167.  
  168. =head1 DATA STRUCTURES
  169.  
  170. Most the the functions in the underlying API allow the programmer to pass
  171. specify at runtime the amount of information that is supplied to the
  172. function. For example, the C<NetUserGetInfo()> call allows the programmer to
  173. specify levels of 0, 1, 2, 3 (and others). Having specified this level, the
  174. function returns a structure that will contain different fields. For a
  175. level C<0>, the function returns a structure that has only one field. For a
  176. supplied level of 1, the function returns a structure with C<8> fields. The
  177. programmer needs to know in advance what fields should be provided or will
  178. be returned for a given level. This mechanism works very will since it
  179. effectively overloads functions without having to use different function
  180. prototypes. Perl provides better higher level data structures in the form
  181. of arrays and hashes. This package uses hashes as the means to pass these
  182. variable size structure into and out of functions.
  183.  
  184. For any function that takes a reference to a hash as input, the programmer
  185. is expected to provide appropriate keys and corresponding values as well as
  186. the level parameter. The called function will then takes the values out of
  187. the supplied hash and build the approprite structure to pass to the
  188. underlying API function.
  189.  
  190. For any function that takes a reference to a hash to recieve output, the
  191. function will first clear any keys an corresponding values in the supplied
  192. hash. It will call the underlying API call and will then return in the hash
  193. any keys and values that are applicable at the requested level.
  194.  
  195. Example:
  196.  
  197. The C<UserGetInfo()> can takes a number of levels. If called with level C<0>
  198. the supplied hash will, on return from the function, contain a single key
  199. and value - namely B<name>/B<requested-users-name>. If called with a level
  200. of C<1> the supplied hash will, on return from the function, contain 8 keys
  201. and values. The returned keys are C<name, password>, C<passwordAge>,
  202. C<priv>, C<homeDir>, C<comment>, C<flags>, C<scriptPath>. See
  203. L<USER INFO FIELDS> for more information on what these represent.
  204.  
  205.  
  206. =head1 Exports
  207.  
  208. By default, Win32API::Net exports no symbols into the callers namespace.
  209. The following tags can be used to selectively import symbols into the
  210. main namespace.
  211.  
  212. =over 8
  213.  
  214. =item C<:User>
  215.  
  216. Exports all symbols needed for the C<User*()> functions.
  217. See L<NET USER FUNCTIONS>.
  218.  
  219. =item C<:Get>
  220.  
  221. Exports all symbols needed for the C<Get*()> functions.
  222. See L<NET GET FUNCTIONS>.
  223.  
  224. =item C<:Group>
  225.  
  226. Exports all symbols needed for the C<Group*()> functions.
  227. See L<NET GROUP FUNCTIONS>.
  228.  
  229. =item C<:LocalGroup>
  230.  
  231. Exports all symbols needed for the C<LocalGroup*()> functions.
  232. See L<NET LOCAL GROUP FUNCTIONS>.
  233.  
  234. =back
  235.  
  236.  
  237. =head1 NET USER FUNCTIONS
  238.  
  239. The C<User*()> functions operate on NT user accounts.
  240.  
  241. Administrator or Account Operator group membership is required to
  242. successfully execute most of these functions on a remote server or on a
  243. computer that has local security enabled. Administrator privileges are
  244. required to add an Administrator Privilege account.  There are some
  245. exceptions to this whereby a user can change some of their own settings
  246. where these don't conflict with 'administrative information' (e.g. full
  247. name).
  248.  
  249. The C<server> field can be the empty string, in which case the function
  250. defaults to running on the local computer. If you leave this field blank
  251. then you should ensure that you are running the function on a PDC or BDC
  252. for your current domain. Use the support function C<GetDCName()> to find out
  253. what the domain controller is, should you not be running this on the PDC.
  254.  
  255. All functions in this section are 'DOMAIN functions'. This means that,
  256. for example, the C<UserGetLocalGroups()> function actually lists the
  257. domain's local groups of which the named user is a member.
  258.  
  259. The following functions are available.
  260.  
  261.  
  262. =head2 UserAdd(server, level, hash, error)
  263.  
  264. Add a new user account. The user name is taken from the C<name>-key's
  265. value in the supplied hash.
  266.  
  267. =over 8
  268.  
  269. =item C<server> - Scalar String
  270.  
  271. The server on which to add the account.
  272.  
  273. =item C<level> - Scalar Int
  274.  
  275. Level of information provided in hash. This can be either 1, 2 or 3.
  276. See L<USER INFO LEVELS>.
  277.  
  278. =item C<hash> - Hash Reference
  279.  
  280. The information to use to add this account. This should have all the
  281. appropriate keys and values required for C<level>.
  282.  
  283. =item C<error> - Scalar Int
  284.  
  285. Provides information on which field in the hash was not properly specified.
  286. See L<USER FIELD ERRORS> for more information about what values this can
  287. take.
  288.  
  289. =back
  290.  
  291. =head2 UserChangePassword(server, user, old, new)
  292.  
  293. Changes the password for C<user>. If the policy of the machine/domain
  294. only allows password changes if the C<user> is logged on then the C<user>
  295. must be logged on to execute this function. With Administrator or Account
  296. Operator privilege you can use this function to change anyone's password,
  297. so long as you know the old password.
  298.  
  299. =over 8
  300.  
  301. =item C<server> - Scalar String
  302.  
  303. The C<server> on which to change the password.
  304.  
  305. =item C<user> - Scalar String
  306.  
  307. The name of the C<user> whose password is being changed.
  308.  
  309. =item C<old> - Scalar String
  310.  
  311. The existing password for C<user>.
  312.  
  313. =item C<new> - Scalar String
  314.  
  315. The new password for C<user>.
  316.  
  317. =back
  318.  
  319.  
  320. =head2 UserDel(server, user)
  321.  
  322. Deletes the specified C<user> account. Administrator or Account Operator
  323. privilege is required to execute this function.
  324.  
  325. =over 8
  326.  
  327. =item C<server> - Scalar String
  328.  
  329. The C<server> on which to delete the C<user>.
  330.  
  331. =item C<user> - Scalar String
  332.  
  333. The C<user> account to delete.
  334.  
  335. =back
  336.  
  337. =head2 UserEnum(server, array[, filter])
  338.  
  339. Enumerates all the accounts on server that satisfy C<filter>. Unlike the
  340. C<NetUserEnum()> function in the API, this function does not allow you
  341. to specify a level (internally it is hardcoded to 0). In Perl it is
  342. trivial to implement the equivalent function (should you need it) - see
  343. L<Example 1>.
  344.  
  345. =over 8
  346.  
  347. =item C<server> - Scalar String
  348.  
  349. The C<server> on which to enumerate the accounts satisfying C<filter>.
  350.  
  351. =item C<array> - Array Reference
  352.  
  353. The array that will hold the names of all users on C<server> whose
  354. accounts match C<filter>.
  355.  
  356. =item C<filter> - Scalar Int (optional)
  357.  
  358. The filter to apply (see L<USER ENUM FILTER>). This argument is optional
  359. and if not present a default of C<FILTER_NORMAL_ACCOUNT> is used.
  360.  
  361. =back
  362.  
  363. =head2 UserGetGroups(server, user, array)
  364.  
  365. Get the global groups for which C<user> is a member. It returns the group
  366. names in C<array>. Unlike the C<NetUserGetGroups()> function in the API,
  367. this function does not allow you to specify a level (internally is
  368. hardcoded to 0). In Perl it is trivial to implement the equivalent function
  369. (in the unlikely event that you might need it).
  370.  
  371. =over 8
  372.  
  373. =item C<server> - Scalar String
  374.  
  375. The C<server> from which to get the groups of which C<user> is a member.
  376.  
  377. =item C<user> - Scalar String
  378.  
  379. The C<user> whose group membership you wish to examine.
  380.  
  381. =item C<array> - Scalar String
  382.  
  383. The array that will contain the group names to which C<user> belongs.
  384.  
  385. =back
  386.  
  387. =head2 UserGetInfo(server, user, level, hash)
  388.  
  389. Returns the information at the specified C<level> for the named C<user>
  390. in C<hash>.
  391.  
  392. =over 8
  393.  
  394. =item C<server> - Scalar String
  395.  
  396. The C<server> from which to get the requested information about C<user>.
  397.  
  398. =item C<user> - Scalar String
  399.  
  400. The C<user> whose information you want.
  401.  
  402. =item C<level> - Scalar Int
  403.  
  404. One of: 0, 1, 2, 3, 10, 11 and 20. See L<USER INFO LEVELS>.
  405.  
  406. =item C<hash> - Hash Reference
  407.  
  408. The hash that will contain the keys and values for the information
  409. requested. See L<USER INFO FIELDS> for information about which keys are
  410. present in a given level.
  411.  
  412. =back
  413.  
  414. =head2 UserGetLocalGroups(server, user, array[, flags])
  415.  
  416. Gets the names of the local groups of which C<user> is a member. Unlike
  417. the C<NetUserEnum()> function in the API, this function does not allow you
  418. to specify a level. Since the underlying API restricts you to level 0 there
  419. really isn't any need to include it...
  420.  
  421. =over 8
  422.  
  423. =item C<server> - Scalar String
  424.  
  425. The server from which to get the local groups of which C<user> is a member.
  426.  
  427. =item C<user> - Scalar String
  428.  
  429. The C<user> whose local group membership you wish to enumerate.
  430.  
  431. =item C<array> - Array Reference
  432.  
  433. The array that will hold the names of the local groups to which C<user>
  434. belongs.
  435.  
  436. =item C<flags> - Scalar Int <em>(optional)</em>
  437.  
  438. Either C<Win32API::Net::LG_INCLUDE_INDIRECT()> or 0. if C<flags> is
  439. omitted, the function internally uses 0. Specifying C<LG_INCLUDE_INDIRECT()>
  440. will include in the list the names of the groups of which the C<user> is
  441. indirectly a member (e.g. by being in a global group that is a member of a
  442. local group).
  443.  
  444. This field can take no other values.
  445.  
  446. =back
  447.  
  448.  
  449. =head2 UserModalsGet()
  450.  
  451. This function is not currently implemented.
  452.  
  453.  
  454. =head2 UserModalsSet()
  455.  
  456. This function is not currently implemented.
  457.  
  458.  
  459. =head2 UserSetGroups(server, user, array)
  460.  
  461. Sets the (global) group membership for C<user> to the specified groups.
  462. Unlike the API function C<NetUserSetGroups()>, this function does not take a
  463. C<level> parameter (mainly because this option is largely redundant).
  464.  
  465. =over 8
  466.  
  467. =item C<server> - Scalar String
  468.  
  469. The C<server> on which you wish to set the group membership for C<user>.
  470.  
  471. =item C<user> - Scalar String
  472.  
  473. The C<user> whose group membership you wish to set.
  474.  
  475. =item C<array> - Array Reference
  476.  
  477. The array containing the (global) group names to set the C<user>s
  478. membership of.
  479.  
  480. =back
  481.  
  482. This function will fail if any of the group names specified do not exist.
  483.  
  484. =head2 UserSetInfo(server, user, level, hash, error)
  485.  
  486. Sets the info for C<user> according to the information contained in C<hash>
  487. for C<level> (see L<USER INFO LEVELS>).
  488.  
  489. =over 8
  490.  
  491. =item C<server> - Scalar String
  492.  
  493. The C<server> on which you wish to change the info for C<user>.
  494.  
  495. =item C<user> - Scalar String
  496.  
  497. The C<user> whose info you wish to change.
  498.  
  499. =item C<level> - Scalar Int
  500.  
  501. One of 0, 1, 2, 3, or 20 (according to Microsoft documentation). In
  502. practice, you can use all the 10xx levels as well to change most of the
  503. individual properties of the named C<user> - although this may not be
  504. supported in future...
  505.  
  506. =item C<hash> - Hash Reference
  507.  
  508. The hash that will contain the necessary key/value pairs required for
  509. C<level> (see L<USER INFO LEVELS>).
  510.  
  511. =item C<error> - Scalar Int
  512.  
  513. Provides information on which field in C<hash> were not properly
  514. specified. See L<USER FIELD ERRORS> for more information about what
  515. values can be returned in this field.
  516.  
  517. =back
  518.  
  519. =head1 NET GROUP FUNCTIONS
  520.  
  521. The C<Group*()> functions all operate only on global groups. To modify
  522. local groups, use the corresponding C<LocalGroup*()> functions.
  523.  
  524. Administrator or Account Operator group membership is required to
  525. successfully execute most of these functions on a remote server or on
  526. a computer that has local security enabled.
  527.  
  528. The C<server> field can be the empty string, in which case the function
  529. defaults to running on the local computer. If you leave this field blank
  530. then you should ensure that you are running the function on a PDC or BDC
  531. for your current domain. Use the support function C<GetDCName()> to find out
  532. what the domain controller is, should you not be running this on the PDC.
  533.  
  534. The following functions are available.
  535.  
  536.  
  537. =head2 GroupAdd(server, level, hash, error)
  538.  
  539. Adds the specified group.
  540.  
  541. =over 8
  542.  
  543. =item C<server> - Scalar String
  544.  
  545. The C<server> on which to add the group.
  546.  
  547. =item C<level> - Scalar String
  548.  
  549. The C<level> of information contained in C<hash>. This can be one of 0, 1
  550. or 2. See L<GROUP INFO LEVELS>.
  551.  
  552. =item C<hash> - Hash Reference
  553.  
  554. A hash containing the required key/value pairs for C<level>.
  555.  
  556. =item C<error> - Scalar Int
  557.  
  558. Provides information on which field in C<hash> was not properly specified.
  559. See L<GROUP FIELD ERRORS> for more information about what values can be
  560. returned in this field.
  561.  
  562. =back
  563.  
  564.  
  565. =head2 GroupAddUser(server, group, user)
  566.  
  567. Adds the specified C<user> to the specified C<group>.
  568.  
  569. =over 8
  570.  
  571. =item C<server> - Scalar String
  572.  
  573. The C<server> on which to add the C<user> to C<group>.
  574.  
  575. =item C<group> - Scalar String
  576.  
  577. The C<group> to add the C<user> to.
  578.  
  579. =item C<user> - Scalar String
  580.  
  581. The C<user> to add to C<group>.
  582.  
  583. =back
  584.  
  585.  
  586.  
  587. =head2 GroupDel(server, group)
  588.  
  589. Deletes the specified global group.
  590.  
  591. =over 8
  592.  
  593. =item C<server> - Scalar String
  594.  
  595. The C<server> on which to delete the named C<group>.
  596.  
  597. =item C<group> -Scalar String
  598.  
  599. The C<group> to delete.
  600.  
  601. =back
  602.  
  603.  
  604.  
  605. =head2 GroupDelUser(server, group, user)
  606.  
  607. Deletes the specified user from the specified group.
  608.  
  609. =over 8
  610.  
  611. =item C<server> - Scalar String
  612.  
  613. The C<server> on which to delete C<user> from C<group>.
  614.  
  615. =item C<group> - Scalar String
  616.  
  617. The C<group> from which to delete C<user>.
  618.  
  619. =item C<user> - Scalar String
  620.  
  621. The C<user> to delete from C<group>.
  622.  
  623. =back
  624.  
  625.  
  626. =head2 GroupEnum(server, array)
  627.  
  628. Enumerates all the global groups on the server. Unlike the API call
  629. C<NetGroupEnum()>, this function does not allow you to specify a level
  630. (internally it is hardcoded to 0). In Perl it is trivial to implement
  631. the equivalent function (should you need it).
  632.  
  633. =over 8
  634.  
  635. =item C<server> - Scalar String
  636.  
  637. The server on which to enumerate the (global) C<groups>.
  638.  
  639. =item C<array> - Array Reference
  640.  
  641. An array that, on return, will contain the C<group> names.
  642.  
  643. =back
  644.  
  645.  
  646. =head2 GroupGetInfo(server, group, level, hash)
  647.  
  648. Retrieves C<level> information for C<group> returning information in
  649. C<hash>.
  650.  
  651. =over 8
  652.  
  653. =item C<server> - Scalar String
  654.  
  655. The C<server> from which to get the group information.
  656.  
  657. =item C<group> - Scalar String
  658.  
  659. The C<group> whose information you wish to obtain.
  660.  
  661. =item C<level> - Scalar Int
  662.  
  663. The C<level> of information you wish to retrieve. This can be one of 1, 2
  664. or 3. See L<GROUP INFO LEVELS>.
  665.  
  666. =item C<hash> - Hash Reference
  667.  
  668. The hash that will contain the information.
  669.  
  670. =back
  671.  
  672.  
  673. =head2 GroupGetUsers(server, group, array)
  674.  
  675. Returns (in C<array>) the users belonging to C<group>. Unlike the API
  676. call C<NetGroupGetUsers()>, this function does not allow you to specify
  677. a level (internally it is hardcoded to 0). In Perl it is trivial to
  678. implement the equivalent function (should you need it).
  679.  
  680. =over 8
  681.  
  682. =item C<server> - Scalar String
  683.  
  684. The C<server> from which to get the group information.
  685.  
  686. =item C<group> - Scalar String
  687.  
  688. The C<group> whose users you wish to obtain.
  689.  
  690. =item C<array> - Array Reference
  691.  
  692. The array to hold the user names retrieved.
  693.  
  694. =back
  695.  
  696. =head2 GroupSetInfo(server, group, level, hash, error)
  697.  
  698. Sets the information for C<group> according to C<level>.
  699.  
  700. =over 8
  701.  
  702. =item C<server> - Scalar String
  703.  
  704. The C<server> on which to set the C<group> information.
  705.  
  706. =item C<group> - Scalar String
  707.  
  708. The C<group> whose information you wish to set.
  709.  
  710. =item C<level> - Scalar Int
  711.  
  712. The C<level> of information you are supplying in C<hash>.  Level can be
  713. one of 0, 1 or 2. See L<GROUP INFO LEVELS>.
  714.  
  715. =item C<hash> - Hash Reference
  716.  
  717. The hash containing the required key/value pairs for C<level>.
  718.  
  719. =item C<error> - Scalar String
  720.  
  721. On failure, the C<error> parameter will contain a value which specifies
  722. which field caused the error. See L<GROUP FIELD ERRORS>.
  723.  
  724. =back
  725.  
  726. =head2 GroupSetUsers(server, group, array)
  727.  
  728. Sets the membership of C<group> to contain only those users specified
  729. in C<array>. This function will fail if any user names contained in the
  730. array are not valid users on C<server>.  On successful completion
  731. C<group> will contain only the users specified in C<array>.  Use the
  732. functions C<GroupAddUser()/GroupDelUser()> to add and delete individual
  733. users from a group.
  734.  
  735. =over 8
  736.  
  737. =item C<server> - Scalar String
  738.  
  739. The C<server> on which to set the C<group> membership.
  740.  
  741. =item C<group> - Scalar String
  742.  
  743. The C<group> to set the membership of.
  744.  
  745. =item C<array> - Array Reference
  746.  
  747. The array containing the names of all users who will be members of C<group>.
  748.  
  749. =back
  750.  
  751. =head1 NET LOCAL GROUP FUNCTIONS
  752.  
  753. The C<LocalGroup*()> functions operate on local groups. If these
  754. functions are run on a PDC then these functions operate on the domains
  755. local groups.
  756.  
  757. Administrator or Account Operator group membership is required to
  758. successfully execute most of these functions on a remote server or on a
  759. computer that has local security enabled.
  760.  
  761. The C<server> field can be the empty string, in which case the function
  762. defaults to running on the local computer. If you leave this field blank
  763. then you should ensure that you are running the function on a PDC or BDC
  764. for your current domain. Use the support function C<GetDCName()> to find
  765. out what the domain controller is, should you not be running this on the PDC.
  766.  
  767. The following functions are available.
  768.  
  769. =head2 LocalGroupAdd(server, level, hash, error)
  770.  
  771. Adds the specified group. The name of the group is contained in the C<name>
  772. key of C<hash>.
  773.  
  774. =over 8
  775.  
  776. =item C<server> - Scalar String
  777.  
  778. The C<server> on which to add the group.
  779.  
  780. =item C<level> - Scalar String
  781.  
  782. The C<level> of information contained in C<hash>. This can be one of 0 or 1.
  783. See L<LOCAL GROUP INFO LEVELS>.
  784.  
  785. =item C<hash> - Hash Reference
  786.  
  787. A hash containing the required key/value pairs for C<level>.
  788.  
  789. =item C<error> - Scalar Int
  790.  
  791. Provides information on which field in C<hash> wasn't properly specified.
  792. See L<LOCAL GROUP FIELD ERRORS> for more information about what values
  793. this can take.
  794.  
  795. =back
  796.  
  797. =head2 LocalGroupAddMember()
  798.  
  799. This function is obselete in the underlying API and has therefore not
  800. been implemented.  Use C<LocalGroupAddMembers> instead.
  801.  
  802. =head2 LocalGroupAddMembers(server, group, array)
  803.  
  804. Adds the specified users (members) to the local group. Unlike the API
  805. function C<NetLocalGroupAddMembers()>, this function does not allow you
  806. to specify a level (internally it is hardcoded to 3).
  807. This was done to simplify the implementation. To add a 'local' user, you
  808. need only specify the C<name>. You can also specify users using the
  809. C<DOMAIN\user> syntax.
  810.  
  811. =over 8
  812.  
  813. =item C<server> - Scalar String
  814.  
  815. The C<server> on which to add the members to C<group>.
  816.  
  817. =item C<group> - Scalar String
  818.  
  819. The C<group> to add the members to.
  820.  
  821. =item C<array> - Array Reference
  822.  
  823. The array containing the members to add to C<group>.
  824.  
  825. =back
  826.  
  827. =head2 LocalGroupDel(server, group)
  828.  
  829. Delete the specified local group.
  830.  
  831. =over 8
  832.  
  833. =item C<server> - Scalar String
  834.  
  835. The C<server> on which to delete the named C<group>.
  836.  
  837. =item C<group> -Scalar String
  838.  
  839. The C<group> to delete.
  840.  
  841. =back
  842.  
  843. =head2 LocalGroupDelMember()
  844.  
  845. This function is obselete in the underlying API and has therefore not
  846. been implemented.  Use C<LocalGroupDelMembers()> instead.
  847.  
  848. =head2 LocalGroupDelMembers(server, group, array)
  849.  
  850. Delete the specified users (members) of the local group. Unlike the API
  851. function C<NetLocalGroupDelMembers()>, this function does not allow you
  852. to specify a level (internally it is hardcoded to 3). This was done to
  853. simplify the implementation. To delete a 'local' user, you need only
  854. specify the C<name>. You can also specify users using the C<DOMAIN\user>
  855. syntax.
  856.  
  857. =over 8
  858.  
  859. =item C<server> - Scalar String
  860.  
  861. The C<server> on which to delete the members from C<group>.
  862.  
  863. =item C<group> - Scalar String
  864.  
  865. The C<group> to delete the members from.
  866.  
  867. =item C<array> - Array Reference
  868.  
  869. The array containing the members to delete from C<group>.
  870.  
  871. =back
  872.  
  873. =head2 LocalGroupEnum(server, array)
  874.  
  875. Enumerates all the local groups on the server. Unlike the API call
  876. C<NetLocalGroupEnum()>, this function does not allow you to specify a
  877. level (internally it is hardcoded to 0). In Perl it is trivial to
  878. implement the equivalent function (should you need it).
  879.  
  880. =over 8
  881.  
  882. =item C<server> - Scalar String
  883.  
  884. The server on which to enumerate the (local) C<groups>.
  885.  
  886. =item C<array> - Array Reference
  887.  
  888. The array to hold the C<group> names.
  889.  
  890. =back
  891.  
  892. =head2 LocalGroupGetInfo(server, group, level, hash)
  893.  
  894. Retrieves C<level> information for C<group>.
  895.  
  896. =over 8
  897.  
  898. =item C<server> - Scalar String
  899.  
  900. The C<server> from which to get the group information.
  901.  
  902. =item C<group> - Scalar String
  903.  
  904. The C<group> whose information you wish to obtain.
  905.  
  906. =item C<level> - Scalar Int
  907.  
  908. The C<level> of information you wish to retrieve. This can be 0 or 1.
  909. See L<LOCAL GROUP INFO LEVELS>.
  910.  
  911. =item C<hash> - Hash Reference
  912.  
  913. The hash that will contain the information.
  914.  
  915. =back
  916.  
  917. =head2 LocalGroupGetMembers(server, group, hash)
  918.  
  919. Retrieves the users belonging to C<group>. Unlike the API call
  920. C<NetLocalGroupGetUsers()>, this function does not allow you to specify
  921. a level (internally it is hardcoded to 0). In Perl it is trivial to
  922. implement the equivalent function (should you need it).
  923.  
  924. =over 8
  925.  
  926. =item C<server> - Scalar String
  927.  
  928. The C<server> from which to retrieve the group information.
  929.  
  930. =item C<group> - Scalar String
  931.  
  932. The C<group> whose users you wish to obtain.
  933.  
  934. =item C<array> - Array Reference
  935.  
  936. The array to hold the user names retrieved.
  937.  
  938. =back
  939.  
  940. =head2 LocalGroupSetInfo(server, level, hash, error)
  941.  
  942. Sets the information for C<group> according to C<level>.
  943.  
  944. =over 8
  945.  
  946. =item C<server> - Scalar String
  947.  
  948. The C<server> on which to set the C<group> information.
  949.  
  950. =item C<group> - Scalar String
  951.  
  952. The C<group> whose information you wish to set.
  953.  
  954. =item C<level> - Scalar Int
  955.  
  956. The C<level> of information you are supplying in C<hash>.
  957. Level can be one of 0 or 1. See L<LOCAL GROUP INFO LEVELS>.
  958.  
  959. =item C<hash> - Hash Reference
  960.  
  961. The hash containing the required key/value pairs for C<level>.
  962.  
  963. =item C<error> - Scalar String
  964.  
  965. On failure, the C<error> parameter will contain a value which specifies
  966. which field caused the error. See L<LOCAL GROUP FIELD ERRORS>.
  967.  
  968. =back
  969.  
  970. =head2 LocalGroupSetMembers()
  971.  
  972. This function has not been implemented at present.
  973.  
  974.  
  975. =head1 NET GET FUNCTIONS
  976.  
  977. =head2 GetDCName(server, domain, domain-controller)
  978.  
  979. Gets the C<domain-controllder> name for C<server> and C<domain>.
  980.  
  981. =over 8
  982.  
  983. =item C<server> - Scalar String
  984.  
  985. The C<server> whose domain controller you wish to locate.
  986.  
  987. =item C<domain> - Scalar String
  988.  
  989. The C<domain> that C<server> is a member of whose domain-controller
  990. you wish the locate.
  991.  
  992. =item C<domain-controller> - Scalar String (output)
  993.  
  994. The name of the C<domain-controller> for the requested C<domain>.
  995.  
  996. =back
  997.  
  998. Note: This module does not implement the C<NetGetAnyDCName()>API function
  999. as this is obsolete.
  1000.  
  1001.  
  1002.  
  1003. =head1 USER INFO LEVELS
  1004.  
  1005. Most of the C<User*()> functions take a C<level> parameter. This C<level>
  1006. specifies how much detail the corresponding C<hash> should contain (or in
  1007. the case of a C<UserGet*()> function, will contain after the call). The
  1008. following C<level> descriptions provide information on what fields should
  1009. be present for a given level. See L<USER INFO FIELDS> for a description of
  1010. the fields.
  1011.  
  1012. =over 8
  1013.  
  1014. =item Level 0
  1015.  
  1016. name
  1017.  
  1018. =item Level 1
  1019.  
  1020. name, password, passwordAge, priv, homeDir, comment, flags, scriptPath
  1021.  
  1022. =item Level 2
  1023.  
  1024. name, password, passwordAge, priv, homeDir, comment, flags, scriptPath,
  1025. authFlags, fullName, usrComment, parms, workstations, lastLogon,
  1026. lastLogoff, acctExpires, maxStorage, unitsPerWeek, logonHours, badPwCount,
  1027. numLogons, logonServer, countryCode, codePage
  1028.  
  1029. =item Level 3
  1030.  
  1031. name, password, passwordAge, priv, homeDir, comment, flags, scriptPath,
  1032. authFlags, fullName, usrComment, parms, workstations, lastLogon, lastLogoff,
  1033. acctExpires, maxStorage, unitsPerWeek, logonHours, badPwCount, numLogons,
  1034. logonServer, countryCode, codePage, userId, primaryGroupId, profile,
  1035. homeDirDrive, passwordExpired
  1036.  
  1037. =item Level 10
  1038.  
  1039. name, comment, usrComment, fullName
  1040.  
  1041. =item Level 11
  1042.  
  1043. name, comment, usrComment, fullName, priv, authFlags, passwordAge, homeDir,
  1044. parms, lastLogon, lastLogoff, badPwCount, numLogons, logonServer,
  1045. countryCode, workstations, maxStorage, unitsPerWeek, logonHours, codePage
  1046.  
  1047. =item Level 20
  1048.  
  1049. name, fullName, comment, flags, userId
  1050.  
  1051. =item Level 21
  1052.  
  1053. B<Not available in this implementation>
  1054.  
  1055. =item Level 22
  1056.  
  1057. B<Not available in this implementation>
  1058.  
  1059. =item Level 1003
  1060.  
  1061. password
  1062.  
  1063. =item Level 1005
  1064.  
  1065. priv
  1066.  
  1067. =item Level 1006
  1068.  
  1069. homeDir
  1070.  
  1071. =item Level 1007
  1072.  
  1073. comment
  1074.  
  1075. =item Level 1008
  1076.  
  1077. flags
  1078.  
  1079. =item Level 1009
  1080.  
  1081. scriptPath
  1082.  
  1083. =item Level 1010
  1084.  
  1085. authFlags
  1086.  
  1087. =item Level 1011
  1088.  
  1089. fullName
  1090.  
  1091. =item Level 1012
  1092.  
  1093. usrComment
  1094.  
  1095. =item Level 1013
  1096.  
  1097. parms
  1098.  
  1099. =item Level 1014
  1100.  
  1101. workstations
  1102.  
  1103. =item Level 1017
  1104.  
  1105. acctExpires
  1106.  
  1107. =item Level 1018
  1108.  
  1109. maxStorage
  1110.  
  1111. =item Level 1020
  1112.  
  1113. unitsPerWeek, logonHours
  1114.  
  1115. =item Level 1023
  1116.  
  1117. logonServer
  1118.  
  1119. =item Level 1024
  1120.  
  1121. countryCode
  1122.  
  1123. =item Level 1025
  1124.  
  1125. codePage
  1126.  
  1127. =item Level 1051
  1128.  
  1129. primaryGroupId
  1130.  
  1131. =item Level 1052
  1132.  
  1133. profile
  1134.  
  1135. =item Level 1053
  1136.  
  1137. homeDirDrive
  1138.  
  1139. =back
  1140.  
  1141.  
  1142.  
  1143. =head1 USER INFO FIELDS
  1144.  
  1145. The following is an alphabetical listing of each possible field, together
  1146. with the data type that the field is expected to contain.
  1147.  
  1148. =over 8
  1149.  
  1150. =item C<acctExpires> - Scalar Int (UTC)
  1151.  
  1152. The time (as the number of seconds since 00:00:00, 1st January 1970) when
  1153. the account expires. A -1 in this field specifies that the account never
  1154. expires.
  1155.  
  1156. =item C<authFlags> - Scalar Int (See USER_AUTH_FLAGS).
  1157.  
  1158. The level of authority that this use has. The value this can take depends
  1159. on the users group membership - this value is therefore read only and
  1160. cannot be set using C<UserAdd()> or C<UserSetInfo()>. Its value can be one
  1161. of:
  1162.  
  1163. =back
  1164.  
  1165.  
  1166.     User belongs to group        Flag value
  1167.     ---------------------        ----------
  1168.     Print Operators            Win32API::Net::AF_OP_PRINT()
  1169.     Server Operators        Win32API::Net::AF_OP_SERVER()
  1170.     Account Operators        Win32API::Net::AF_OP_ACCOUNTS()
  1171.  
  1172.  
  1173. =over 8
  1174.  
  1175. =item C<badPwCount> - Scalar Int
  1176.  
  1177. The number of times that the user has failed to logon by specifying an
  1178. incorrect password.
  1179.  
  1180. =item C<codePage> - Scalar Int
  1181.  
  1182. The code page that this user uses.
  1183.  
  1184. =item C<comment> - Scalar String
  1185.  
  1186. The comment associated with this user account. This can be any string
  1187. (apparently of any length).
  1188.  
  1189. =item C<countryCode> - Scalar Int
  1190.  
  1191. The country code that this user uses.
  1192.  
  1193. =item C<flags> - Scalar Int (Bitwise OR of USER_FLAGS)
  1194.  
  1195. The flags for this user. See L<USER FLAGS>.
  1196.  
  1197. =item C<fullName> - Scalar String
  1198.  
  1199. The users' full name.
  1200.  
  1201. =item C<homeDir> - Scalar String
  1202.  
  1203. The home directory of the user. This can be either a UNC path or an
  1204. absolute path (drive letter + path). Can be the empty string ("").
  1205.  
  1206. =item C<homeDirDrive> - Scalar String
  1207.  
  1208. The home directory drive that the users home directory is mapped to
  1209. (assuming that the specified home directory is a UNC path).
  1210.  
  1211. =item C<lastLogon> - Scalar Int (UTC)
  1212.  
  1213. The time (as the number of seconds since 00:00:00, 1st January 1970)
  1214. that the user last logged on.
  1215.  
  1216. =item C<lastLogoff> - Scalar Int (UTC)
  1217.  
  1218. The time (as the number of seconds since 00:00:00, 1st January 1970)
  1219. that the user last logged off .
  1220.  
  1221. =item C<logonHours> - Reference to Array of Integers (length 21 elements)
  1222.  
  1223. The times at which the user can logon. This should be an integer array
  1224. with 21 elements.  Each element represents an 8 hour period and each bit
  1225. represents represents an hour. Only the lower byte of each integer is
  1226. used. If this is left undefined then no restrictions are placed on the
  1227. account.
  1228.  
  1229. =item C<logonServer> - Scalar String
  1230.  
  1231. The logon server for this user. Under Windows NT, this value cannot be
  1232. set and will always have the value '\\*' when queried.
  1233.  
  1234. =item C<maxStorage> - Scalar Int
  1235.  
  1236. The current release of Windows NT does not implement disk quotas so
  1237. it is believed that the value of this key is ignored.
  1238.  
  1239. =item C<name> - Scalar String
  1240.  
  1241. The user name that this request applies to. Most of the functions take
  1242. the user name as a separate argument. In general, the user name provided
  1243. should be the same as that in the one provided in the hash.
  1244.  
  1245. =item C<numLogons> - Scalar Int
  1246.  
  1247. The number of times that the named user has successfully logged on to
  1248. this machine/domain.
  1249.  
  1250. =item C<parms> - Scalar String
  1251.  
  1252. The value of this key can be used by applications. There are none known
  1253. to to author that use it, although it could be used to hold adminitrative
  1254. information.
  1255.  
  1256. =item C<password> - Scalar String
  1257.  
  1258. The password to be set. The password is never returned in a C<UserGet()>
  1259. operation.
  1260.  
  1261. =item C<passwordAge> - Scalar Int (UTC)
  1262.  
  1263. The current age of the password (stored as the number of seconds since
  1264. 00:00:00, 1st January 1970).
  1265.  
  1266. =item C<passwordExpired> - Scalar Int
  1267.  
  1268. The value of this key is used in two different ways. When queried via
  1269. C<UserGetInfo()> the return value is 0 is the password has not expired
  1270. and 1 if it has. When setting the value via C<UserAdd()> or
  1271. C<UserSetInfo()> a value of 0 indicates that the users' password has
  1272. not expired whereas a value of 1 will force the user to change their
  1273. password at the next logon.
  1274.  
  1275. =item C<primaryGroupId> - Scalar Int
  1276.  
  1277. The id of the primary group that this user belongs to. When creating
  1278. accounts with C<UserAdd()> you should use a value of 0x201.
  1279.  
  1280. =item C<priv> - Scalar Int (Bitwise OR of USER_PRIVILEGE_FLAGS)
  1281.  
  1282. The privilege level that this user has. This is never returned from a
  1283. C<UserGet()> call. See L<USER PRIVILEGE FLAGS>.
  1284.  
  1285. =item C<profile> - Scalar String
  1286.  
  1287. The profile that is associated with the named user. This can be UNC path,
  1288. a local path or undefined.
  1289.  
  1290. =item C<scriptPath> - Scalar String
  1291.  
  1292. The path to the logon script for this user. This should be specified as a
  1293. relative path and will cause the logon script to be run from (relative
  1294. location) in the logon servers export directory.
  1295.  
  1296. =item C<unitsPerWeek> - Scalar Int
  1297.  
  1298. The value of this key represents the granularity of the logonHours array.
  1299. Its use is beyond the scope of this package.
  1300.  
  1301. =item C<usrComment> - Scalar String
  1302.  
  1303. The user comment field (contrasted with the comment field ;-).
  1304.  
  1305. =item C<workstations> - Scalar String
  1306.  
  1307. A comma-separated string containing upto 8 workstation that the named
  1308. user can login to.  Setting a value for this key will then allow the
  1309. named user to login to only those computers named.
  1310.  
  1311. =item C<userId> - Scalar Int
  1312.  
  1313. The user id associated with this user This value is generated by the
  1314. system and cannot be set or changed using the C<UserAdd()> or
  1315. C<UserSetInfo()> calls.
  1316.  
  1317. =back
  1318.  
  1319.  
  1320.  
  1321. =head1 USER FLAGS
  1322.  
  1323. The following is an alphabetical listing of the user flags.
  1324. The C<flags> key (see L<USER INFO FIELDS>) should be the bitwise OR of one
  1325. or more of these values.
  1326.  
  1327. =over 8
  1328.  
  1329. =item C<UF_ACCOUNTDISABLE()>
  1330.  
  1331. This account has been disabled.
  1332.  
  1333. =item C<UF_DONT_EXPIRE_PASSWORD()>
  1334.  
  1335. Never expire the password on this account.
  1336.  
  1337. =item C<UF_HOMEDIR_REQUIRED()>
  1338.  
  1339. A home directory must be specified (ignored for NT).
  1340.  
  1341. =item C<UF_INTERDOMAIN_TRUST_ACCOUNT()>
  1342.  
  1343. The account represents a interdomain trust account.
  1344.  
  1345. =item C<UF_LOCKOUT()>
  1346.  
  1347. Lock out this account (or this account has been locked out due to
  1348. security policy - i.e.  badLogonCount is greater than your policy allows).
  1349. This value can be cleared but not set by a C<UserSetInfo()> call.
  1350.  
  1351. =item C<UF_NORMAL_ACCOUNT()>
  1352.  
  1353. The account is a normal user account.
  1354.  
  1355. =item C<UF_PASSWD_CANT_CHANGE()>
  1356.  
  1357. The password for this account cannot be changed (execpt by an Administrator
  1358. using one of the above calls).
  1359.  
  1360. =item C<UF_PASSWD_NOTREQD()>
  1361.  
  1362. A password is not required for this account.
  1363.  
  1364. =item C<UF_SCRIPT()>
  1365.  
  1366. This <strong>must be set when creating account on Windows NT.
  1367.  
  1368. =item C<UF_SERVER_TRUST_ACCOUNT()>
  1369.  
  1370. The account represents a Windows NT Backup Domain Controller account in
  1371. the domain.
  1372.  
  1373. =item C<UF_TEMP_DUPLICATE_ACCOUNT()>
  1374.  
  1375. To quote the Microsoft Documentation <em>"This is an account for
  1376. users whose primary account is in another domain. This account provides
  1377. user access to this domain, but not to any domain that trusts this domain.
  1378. The User Manager refers to this account type as a local user account.
  1379.  
  1380. =item C<UF_WORKSTATION_TRUST_ACCOUNT()>
  1381.  
  1382. The account represents a computer account for a workstation or server in
  1383. the domain.
  1384.  
  1385. =back
  1386.  
  1387. Please note that these are implemented as functions and are therefore
  1388. called in the same way as other functions. You should typically use them
  1389. like:
  1390.  
  1391.     $ufScript = Win32API::Net::UF_SCRIPT();
  1392.  
  1393. =head1 USER PRIVILEGE FLAGS
  1394.  
  1395. These following values are used in the C<priv> key. This field is never
  1396. initialised on a C<UserGet*()> call and once set cannot be changed in a
  1397. C<UserSetInfo()> call.
  1398.  
  1399. =over 8
  1400.  
  1401. =item C<USER_PRIV_ADMIN()>
  1402.  
  1403. Account is an an administrative account.
  1404.  
  1405. =item C<USER_PRIV_GUEST()>
  1406.  
  1407. Account is a guest account.
  1408.  
  1409. =item C<USER_PRIV_USER()>
  1410.  
  1411. Account is a user account.
  1412.  
  1413. =back
  1414.  
  1415. Please note that these are implemented as functions and are therefore
  1416. called in the same way as other functions. You should typically use them
  1417. like:
  1418.  
  1419.     $userPrivUser = Win32API::Net::USER_PRIV_USER();
  1420.  
  1421. =head1 USER ENUM FILTER
  1422.  
  1423. These flags are used in the C<UserEnum()> function to specify which
  1424. accounts to retrieve. It should be a bitwise OR of some (or all) of
  1425. the following.
  1426.  
  1427. =over 8
  1428.  
  1429. =item C<FILTER_TEMP_DUPLICATE_ACCOUNT()>
  1430.  
  1431. Show temporary duplicate account (one presumes).
  1432.  
  1433. =item C<FILTER_NORMAL_ACCOUNT()>
  1434.  
  1435. Show normal user account.
  1436.  
  1437. =item C<FILTER_INTERDOMAIN_TRUST_ACCOUNT()>
  1438.  
  1439. Show interdomain trust accounts.
  1440.  
  1441. =item C<FILTER_WORKSTATION_TRUST_ACCOUNT()>
  1442.  
  1443. Show workstation trust accounts.
  1444.  
  1445. =item C<FILTER_SERVER_TRUST_ACCOUNT()>
  1446.  
  1447. Show server trust accounts.
  1448.  
  1449. =back
  1450.  
  1451. Please note that these are implemented as functions and are therefore
  1452. called in the same way as other functions. You should typically use them
  1453. like:
  1454.  
  1455.     $filterNormalAccounts = Win32API::Net::FILTER_NORMAL_ACCOUNT();
  1456.  
  1457. =head1 USER FIELD ERRORS
  1458.  
  1459. For the C<User*()> functions that take an C<error> parameter this variable
  1460. will, on failure, contain one of the following constants. Note that the
  1461. function may fail because more than one key/value was missing from the
  1462. input hash. You will only find out about the first one that was incorrectly
  1463. specified. This is only really useful in debugging.
  1464.  
  1465. =over 8
  1466.  
  1467. =item C<USER_ACCT_EXPIRES_PARMNUM()>
  1468.  
  1469. C<acctExpires> field was absent or not correctly specified.
  1470.  
  1471. =item C<USER_AUTH_FLAGS_PARMNUM()>
  1472.  
  1473. C<authFlags> field was absent or not correctly specified.
  1474.  
  1475. =item C<USER_BAD_PW_COUNT_PARMNUM()>
  1476.  
  1477. C<badPasswordCount> field was absent or not correctly specified.
  1478.  
  1479. =item C<USER_CODE_PAGE_PARMNUM()>
  1480.  
  1481. C<codePage> field was absent or not correctly specified.
  1482.  
  1483. =item C<USER_COMMENT_PARMNUM()>
  1484.  
  1485. C<comment> field was absent or not correctly specified.
  1486.  
  1487. =item C<USER_COUNTRY_CODE_PARMNUM()>
  1488.  
  1489. C<countryCode> field was absent or not correctly specified.
  1490.  
  1491. =item C<USER_FLAGS_PARMNUM()>
  1492.  
  1493. C<flags> field was absent or not correctly specified.
  1494.  
  1495. =item C<USER_FULL_NAME_PARMNUM()>
  1496.  
  1497. C<fullName> field was absent or not correctly specified.
  1498.  
  1499. =item C<USER_HOME_DIR_DRIVE_PARMNUM()>
  1500.  
  1501. C<homeDirDrive> field was absent or not correctly specified.
  1502.  
  1503. =item C<USER_HOME_DIR_PARMNUM()>
  1504.  
  1505. C<homeDir> field was absent or not correctly specified.
  1506.  
  1507. =item C<USER_LAST_LOGOFF_PARMNUM()>
  1508.  
  1509. C<lastLogoff> field was absent or not correctly specified.
  1510.  
  1511. =item C<USER_LAST_LOGON_PARMNUM()>
  1512.  
  1513. C<lastLogon> field was absent or not correctly specified.
  1514.  
  1515. =item C<USER_LOGON_HOURS_PARMNUM()>
  1516.  
  1517. C<logonHours> field was absent or not correctly specified.
  1518.  
  1519. =item C<USER_LOGON_SERVER_PARMNUM()>
  1520.  
  1521. C<logonServer> field was absent or not correctly specified.
  1522.  
  1523. =item C<USER_MAX_STORAGE_PARMNUM()>
  1524.  
  1525. C<maxStorage> field was absent or not correctly specified.
  1526.  
  1527. =item C<USER_NAME_PARMNUM()>
  1528.  
  1529. C<name> field was absent or not correctly specified.
  1530.  
  1531. =item C<USER_NUM_LOGONS_PARMNUM()>
  1532.  
  1533. C<numLogons> field was absent or not correctly specified.
  1534.  
  1535. =item C<USER_PARMS_PARMNUM()>
  1536.  
  1537. C<parms> field was absent or not correctly specified.
  1538.  
  1539. =item C<USER_PASSWORD_AGE_PARMNUM()>
  1540.  
  1541. C<passwordAge> field was absent or not correctly specified.
  1542.  
  1543. =item C<USER_PASSWORD_PARMNUM()>
  1544.  
  1545. C<password> field was absent or not correctly specified.
  1546.  
  1547. =item C<USER_PRIMARY_GROUP_PARMNUM()>
  1548.  
  1549. C<primaryGroup> field was absent or not correctly specified.
  1550.  
  1551. =item C<USER_PRIV_PARMNUM()>
  1552.  
  1553. C<priv> field was absent or not correctly specified.
  1554.  
  1555. =item C<USER_PROFILE_PARMNUM()>
  1556.  
  1557. C<profile> field was absent or not correctly specified.
  1558.  
  1559. =item C<USER_SCRIPT_PATH_PARMNUM()>
  1560.  
  1561. C<scriptPath> field was absent or not correctly specified.
  1562.  
  1563. =item C<USER_UNITS_PER_WEEK_PARMNUM()>
  1564.  
  1565. C<unitPerWeek> field was absent or not correctly specified.
  1566.  
  1567. =item C<USER_USR_COMMENT_PARMNUM()>
  1568.  
  1569. C<usrComment> field was absent or not correctly specified.
  1570.  
  1571. =item C<USER_WORKSTATIONS_PARMNUM()>
  1572.  
  1573. C<workstations> field was absent or not correctly specified.
  1574.  
  1575. =back
  1576.  
  1577.  
  1578. =head1 GROUP INFO LEVELS
  1579.  
  1580. Some of the C<Group*()> functions take a C<level> parameter. This C<level>
  1581. specifies how much detail the corresponding C<hash> should contain (or in
  1582. the case of a C<GroupGetInfo()> function, will contain after the call).
  1583. The following C<level> descriptions provide information on what fields
  1584. should be present for a given level. See L<GROUP INFO FIELDS>
  1585. for a description of the fields.
  1586.  
  1587. =over 8
  1588.  
  1589. =item C<Level 0>
  1590.  
  1591. name.
  1592.  
  1593. =item C<Level 1>
  1594.  
  1595. name, comment.
  1596.  
  1597. =item C<Level 2>
  1598.  
  1599. name, comment, groupId, attributes.
  1600.  
  1601. =item C<Level 1002>
  1602.  
  1603. comment.
  1604.  
  1605. =item C<Level 1005>
  1606.  
  1607. attributes.
  1608.  
  1609. =back
  1610.  
  1611.  
  1612. =head1 GROUP INFO FIELDS
  1613.  
  1614. =over 8
  1615.  
  1616. =item C<attributes> - Scalar Int
  1617.  
  1618. The attributes of the group. These are no longer settable in Windows NT 4.0
  1619. and they are not currently supported in this package either.
  1620.  
  1621. =item C<comment> - Scalar String
  1622.  
  1623. The C<comment> that applies to this group. This is the only value that
  1624. can be set via a GroupSetInfo call.
  1625.  
  1626. =item C<groupId> - Scalar Int
  1627.  
  1628. The groups Id.
  1629.  
  1630. =item C<name> - Scalar String
  1631.  
  1632. The groups name.
  1633.  
  1634. =back
  1635.  
  1636.  
  1637.  
  1638. =head1 GROUP FIELD ERRORS
  1639.  
  1640. For the C<Group*()> functions that take an C<error> parameter
  1641. this variable will, on failure, contain one of the following constants.
  1642. Note that the function may fail because more than one key/value was
  1643. missing from the input hash. You will only find out about the first one
  1644. that was incorrectly specified. This is only really useful for debugging
  1645. purposes.
  1646.  
  1647. =over 8
  1648.  
  1649. =item C<GROUP_ATTRIBUTES_PARMNUM()>
  1650.  
  1651. C<attributes> field was absent or not correctly specified.
  1652.  
  1653. =item C<GROUP_COMMENT_PARMNUM()>
  1654.  
  1655. C<comment> field was absent or not correctly specified.
  1656.  
  1657. =item C<GROUP_NAME_PARMNUM()>
  1658.  
  1659. C<name> field was absent or not correctly specified.
  1660.  
  1661. =back
  1662.  
  1663.  
  1664.  
  1665. =head1 GROUP USERS INFO LEVELS
  1666.  
  1667. The C<GroupGetUsers()> function can take a level of 0 or 1. These will
  1668. return the following:
  1669.  
  1670. =over 8
  1671.  
  1672. =item C<Level 0>
  1673.  
  1674. name.
  1675.  
  1676. =item C<Level 1>
  1677.  
  1678. name, attributes.
  1679.  
  1680. =back
  1681.  
  1682.  
  1683. =head1 GROUP USERS INFO FIELDS
  1684.  
  1685. =over 8
  1686.  
  1687. =item C<name> - Scalar String
  1688.  
  1689. The user's name.
  1690.  
  1691. =item C<attributes> - Scalar Int
  1692.  
  1693. The attributes of the group. These are no longer settable in Windows NT
  1694. 4.0 and they are not currently supported in this package either.
  1695.  
  1696. =back
  1697.  
  1698.  
  1699.  
  1700. =head1 LOCAL GROUP INFO LEVELS
  1701.  
  1702. =over 8
  1703.  
  1704. =item C<Level 0>
  1705.  
  1706. name
  1707.  
  1708. =item C<Level 1>
  1709.  
  1710. name, comment
  1711.  
  1712. =item C<Level 1002>
  1713.  
  1714. comment
  1715.  
  1716.  
  1717. =back
  1718.  
  1719.  
  1720.  
  1721. =head1 LOCAL GROUP INFO FIELDS
  1722.  
  1723. =over 8
  1724.  
  1725. =item C<name> - Scalar String
  1726.  
  1727. The groups name
  1728.  
  1729. =item C<comment> - Scalar String
  1730.  
  1731. The groups 'comment'
  1732.  
  1733. =back
  1734.  
  1735.  
  1736. =head1 LOCAL GROUP FIELD ERRORS
  1737.  
  1738. For the C<LocalGroup*()> functions that take an C<error> parameter this
  1739. variable will, on failure, contain one of the following constants. Note
  1740. that the function may fail because more than one key/value was missing
  1741. or incorrectly specified in the input hash. You will only find out about
  1742. the first one that was incorrectly specified. This is only really useful
  1743. for debugging purposes.
  1744.  
  1745. =over 8
  1746.  
  1747. =item C<LOCALGROUP_NAME_PARMNUM()>
  1748.  
  1749. The C<name> field was absent or not correctly specified.
  1750.  
  1751. =item C<LOCALGROUP_COMMENT_PARMNUM()>
  1752.  
  1753. The C<comment> field wasabsent or not correctly specified.
  1754.  
  1755. =back
  1756.  
  1757. =head1 EXAMPLES
  1758.  
  1759. The following example shows how you can create a function in Perl that
  1760. has the same functionality as the C<NetUserEnum()> API call. The Perl
  1761. version doesn't have the level parameter so you must first use the
  1762. C<UserEnum()> function to retrieve all the account names and then iterate
  1763. through the returned array issuing C<UserGetInfo()> calls.
  1764.  
  1765.     sub userEnumAtLevel {
  1766.        my($server, $level, $filter) = @_;
  1767.        my(@array);
  1768.        Win32API::Net::UserEnum($server, \@array, $filter);
  1769.        for $user (@array) {
  1770.       Win32API::Net::UserGetInfo($server, $user, $level, \%hash);
  1771.       print "This could access all level $level settings for $user - eg fullName $hash{fullName}\n";
  1772.        }
  1773.     }
  1774.     userEnumAtLevel("", 2, 0);
  1775.  
  1776.  
  1777.  
  1778. =head1 AUTHOR
  1779.  
  1780. Bret Giddings, <bret@essex.ac.uk>
  1781.  
  1782.  
  1783. =head1 SEE ALSO
  1784.  
  1785. C<perl(1)>
  1786.  
  1787.  
  1788. =head1 ACKNOWEDGEMENTS
  1789.  
  1790. This work was built upon work done by HiP Communications along with
  1791. modifications to HiPs code by <michael@ecel.uwa.edu.au> and <rothd@roth.net>.
  1792. In addition, I would like to thank Jenny Emby at GEC Marconi, U.K. for
  1793. proof reading this manual page and making many suggestions that have led
  1794. to its current layout. Last but not least I would like to thank Larry Wall
  1795. and all the other Perl contributors for making this truly wonderful
  1796. language.
  1797.  
  1798. =cut
  1799.